package com.jade.bss.admin.principal;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.jade.bss.admin.account.AdminAccount;
import com.jade.framework.base.security.AbstractPrincipal;
import org.apache.commons.lang3.StringUtils;

/**
 * 管理员登录以后的principal.
 *
 * @author Daisy
 * @version 1.0 14-10-7 上午11:46
 */
public class AdminPrincipal  extends AbstractPrincipal
{
    private long id;
    private String trueName;
    private Date lastLoginTime;
    private String ownerId;
    private String ownerType;
    private String clientAddress;
    private String clientType;
    private String type;
    private Map<String, String> appIds = new HashMap<String, String>();
    private Object userInfo;
    private Map parameters = new HashMap();

    public String getTrueName()
    {
        return trueName;
    }

    public void setTrueName(String trueName)
    {
        this.trueName = trueName;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getClientAddress()
    {
        return clientAddress;
    }

    public void setClientAddress(String clientAddress)
    {
        this.clientAddress = clientAddress;
    }

    public String getClientType()
    {
        return clientType;
    }

    public void setClientType(String clientType)
    {
        this.clientType = clientType;
    }

    public String getOwnerId()
    {
        return ownerId;
    }

    public void setOwnerId(String ownerId)
    {
        this.ownerId = ownerId;
    }

    public String getOwnerType()
    {
        return ownerType;
    }

    public void setOwnerType(String ownerType)
    {
        this.ownerType = ownerType;
    }

    public long getId()
    {
        return id;
    }

    public Date getLastLoginTime()
    {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime)
    {
        this.lastLoginTime = lastLoginTime;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public String getAppId(String code)
    {
        return appIds.get(code);
    }

    public void setAppId(String code, String appId)
    {
        appIds.put(code, appId);
    }

    public Map getParameters()
    {
        return parameters;
    }

    public void setParameters(Map parameters)
    {
        this.parameters = parameters;
    }

    public Object getParameter(Object key)
    {
        return parameters.get(key);
    }

    public void setParameter(Object key, Object value)
    {
        parameters.put(key, value);
    }

    public <T> T getUserInfo()
    {
        return (T) userInfo;
    }

    public void setUserInfo(Object userInfo)
    {
        this.userInfo = userInfo;
    }

    @Override
    public boolean isSuperman()
    {
        return StringUtils.equalsIgnoreCase(AdminAccount.DEFAULT_OWNER_TYPE, ownerType) && id == 1;
    }
}

